package com.example.springbootmybatis.controller;

import com.example.springbootmybatis.mapper.RoleMapper;
import com.example.springbootmybatis.entity.Role;
import com.example.springbootmybatis.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


/**
 * @title: RoleController
 * @Author Tan
 * @Date: 2021/6/3 20:38
 * @Version 1.0
 */
@RestController
public class RoleController {
    /*
     * @Description: 权限Mapper
     * @Date: 2021/6/5 18:01
     */
    @Resource
    private RoleService roleService;

    /*
     * @Description: 变量的依赖注入最好通过构造器或者Set方法注入
     * @Date: 2021/6/5 18:00
     */
    @Autowired
    public RoleController(RoleService roleService) {
        this.roleService = roleService;
    }

    @RequestMapping("/getRoleById/{id}")
    public Role getRoleById(@PathVariable("id")Integer id) {
        Role role = roleService.selectByPrimaryKey(id);
        return role;
    }
}

